package com.lxy.demo.service;

import com.lxy.demo.dao.ToursInfoDao;
import com.lxy.demo.dao.ToursInfoDaoImpl;
import com.lxy.demo.entity.Condition;
import com.lxy.demo.entity.ToursInfo;
import com.lxy.demo.utils.PageBean;

import java.util.List;

public class ToursInfoServiceImpl implements ToursInfoService {
    ToursInfoDao t = new ToursInfoDaoImpl();

    @Override
    public boolean addInfo(ToursInfo toursInfo) {
        return t.addInfo(toursInfo) > 0 ? true : false;
    }

    @Override
    public PageBean findInfoBySome(Condition condition, Integer p) {
        PageBean pb = new PageBean();
        pb.setPageSize(3);  //设置一页3条记录
        int count = t.findCount(condition);  //查询总记录
        pb.setPageTotal(count);     //设置总记录条数，并且获得一共有多少页
        pb.setP(p);
        pb.setDataList(t.findInfoBySome(condition, pb.getP()));
        return pb;
    }

    @Override
    public boolean delInfo(int id) {
        return t.delInfo(id) > 0 ? true : false;
    }

    @Override
    public ToursInfo findOne(int id) {
        return t.findOne(id);
    }

    @Override
    public boolean update(int id, ToursInfo toursInfo) {
        return t.updInfo(id, toursInfo) > 0;
    }
}
